<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-item/paper-item.html">

<dom-module id='vz-projector-data-loader'>
<template>
<style>
:host {
}

input[type=file] {
  display: none;
}

.file-name {
  margin-right: 10px;
}

.dirs {
  display: flex;
  flex-direction: column;
  margin-right: 10px;
  line-height: 20px;
}

.dir {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

paper-item {
  --paper-item-disabled: {
    border-bottom: 1px solid black;
    justify-content: center;
    font-size: 12px;
    line-height: normal;
    min-height: 0px;
  };
}
</style>

<!-- Server-mode UI -->
<div class="server-controls" style="display:none;">
  <div class="dirs">
    <div class="dir">Checkpoint: <span id="checkpoint-file"></span></div>
    <div class="dir">Metadata: <span id="metadata-file"></span></div>
  </div>
  <!-- List of tensors in checkpoint -->
  <paper-dropdown-menu noink no-animations label="[[getNumTensorsLabel(tensorNames)]] found">
    <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedTensor}}">
      <template is="dom-repeat" items="[[tensorNames]]">
        <paper-item style="justify-content: space-between;" value="[[item.name]]" label="[[item.name]]">
          [[item.name]]
          <span style="margin-left: 5px; color:gray; font-size: 12px;">[[item.shape.0]]x[[item.shape.1]]</span>
        </paper-item>
      </template>
    </paper-listbox>
  </paper-dropdown-menu>
</div>

<!-- Standalone-mode UI -->
<div class="standalone-controls" style="display:none;">

  <!-- Upload buttons -->
  <div style="display: flex; justify-content: space-between;">
    <!-- Upload data -->
    <div>
      <button id="upload" title="Upload a TSV file" class="ink-button">Upload data</button>
      <span id="file-name" class="file-name dir"></span>
      <input type="file" id="file" name="file"/>
    </div>

    <!-- Upload metadata -->
    <div>
      <button id="upload-metadata" title="Upload a TSV metadata file" class="ink-button">Upload Metadata</button>
      <span id="file-metadata-name" class="file-name dir"></span>
      <input type="file" id="file-metadata" name="file-metadata"/>
    </div>
  </div>

  <!-- Demo datasets -->
  <paper-dropdown-menu style="width: 100%" noink no-animations label="Select a demo dataset">
    <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedDemo}}">
        <paper-item value="smartreply_full">SmartReply All</paper-item>
        <paper-item value="smartreply_5k">SmartReply 5K</paper-item>
        <paper-item value="wiki_5k">Glove Wiki 5K</paper-item>
        <paper-item value="wiki_10k">Glove Wiki 10K</paper-item>
        <paper-item value="wiki_40k">Glove Wiki 40K</paper-item>
        <paper-item value="mnist_10k">MNIST 10K</paper-item>
        <paper-item value="iris">Iris</paper-item>
    </paper-listbox>
  </paper-dropdown-menu>

</div>

<!-- Label by -->
<template is="dom-if" if="[[labelOptions.length]]">
  <paper-dropdown-menu style="width: 100%" noink no-animations label="Label by">
    <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{labelOption}}">
      <template is="dom-repeat" items="[[labelOptions]]">
        <paper-item style="justify-content: space-between;" value="[[item]]" label="[[item]]">
          [[item]]
        </paper-item>
      </template>
    </paper-listbox>
  </paper-dropdown-menu>
</template>

<!-- Color by -->
<template is="dom-if" if="[[colorOptions.length]]">
  <paper-dropdown-menu id="colorby" style="width: 100%" noink no-animations label="Color by">
    <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{colorOption}}">
      <template is="dom-repeat" items="[[colorOptions]]">
        <paper-item style="justify-content: space-between;" class$="[[getSeparatorClass(item.isSeparator)]]" value="[[item]]" label="[[item.name]]" disabled="[[item.isSeparator]]">
          [[item.name]]
          <span style="margin-left: 5px; color:gray; font-size: 12px;">[[item.desc]]</span>
        </paper-item>
      </template>
    </paper-listbox>
  </paper-dropdown-menu>
</template>

<!-- Closing global template -->
</template>
</dom-module>
